<?php
$rootPath = str_replace('wp-content/themes/wp-foundation/lib/extensions/options-backup', '' ,dirname(__FILE__));
require_once($rootPath . '/wp-config.php');
require_once(THEMELIB . "/classes/upload.php");


if($_FILES['upload']['tmp_name']) {
    $upload = new Upload();
    $upload->SetFileName($_FILES['upload']['name']);
    $upload->SetTempName($_FILES['upload']['tmp_name']);
    $upload->SetUploadDirectory(THEMELIB . "/extensions/options-backup/"); //Upload directory, this should be writable
    $upload->SetValidExtensions(array('xml')); //Extensions that are allowed if none are set all extensions will be allowed.
    //$upload->SetEmail("Sidewinder@codecall.net"); //If this is set, an email will be sent each time a file is uploaded.
    //$upload->SetIsImage(true); //If this is set to be true, you can make use of the MaximumWidth and MaximumHeight functions.
    //$upload->SetMaximumWidth(60); // Maximum width of images
    //$upload->SetMaximumHeight(400); //Maximum height of images
    $upload->SetMaximumFileSize(300000); //Maximum file size in bytes, if this is not set, the value in your php.ini file will be the maximum value
    if ($upload->GetMessage() == "No Message"){
    	echo '<em>' . $upload->GetFileName() . '</em> was uploaded to the server.<br/> Refresh options page to see new file listing.<br/>';
    }else{
    	echo $upload->GetMessage();
    }
    $upload->UploadFile();
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" method="POST">
	<input name="upload" type="file" />
	<input type="submit" value="Upload" />
</form>